<?php
	
	interface IbLinqStore {
		
		public function Add($oLinq);
		public function Select($oLinq);
		public function Equal($oLinq, $mValue);
//		public function Merge($oLinq, $mValue =null);
		public function GreaterThan($oLinq, $mValue);
		public function LessThan($oLinq, $mValue);
		public function StartsWith($oLinq, $mValue);
		public function Contains($oLinq, $mValue);
		public function EndsWith($oLinq, $mValue);
	}

	class bLinqStore {
	
		protected function AsCsv($aArray, $s ="'") {
			
			is_array($aArray) or $aArray =array();
			return $s.implode($s.','.$s, array_map('mysql_escape_string', $aArray)).$s;
		}
		
		protected function AsKeyValueString($aArray, $s ="'") {
			
			$aReturn =array();
			is_array($aArray) or $aArray =array();
			
//-			$aReturn =array_map(array($this, 'AsKeyValue'), array_keys($aArray), array_values($aArray));
			
//*			$sKey =array_keys($aArray);
//*			$sValues =array_map('mysql_escape_string', array_values($aArray));
//*			$aKeyValue =array_fill(0, count($aArray), '%s='.$s.'%s'.$s);
//*			
//*			$aReturn =array_map('sprintf', $aKeyValue, $sKey, $sValues);

			foreach($aArray as $sKey =>$sValue) { 
			
				$sValueOf = $sValue ===null ? 'NULL' : $s.mysql_escape_string($sValue).$s;
				$aReturn[] =$sKey."=".$sValueOf;
			}
			
			return implode(', ', $aReturn);
		}
		
		private function AsKeyValue($sKey, $sValue) {
			
			$s ="'";
			return $sKey."="
				.($sValue ===null ? 'NULL' : $s.mysql_escape_string($sValue).$s);
		}
	}

?>